From 6fa7fb4d9f39071f12a6e7cc8bb88ea47abece89 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonas=20=C3=85dahl?= Date: Mon, 23 Mar 2026 13:26:51 +0100 Subject: [PATCH] st/texture-cache: Add missing error reporting st_texture_cache_load_file_sync_to_cogl_texture() loads a file into a texture, but if pixbuf_to_st_content_image() failed, it'd return that it failed, but wouldn't set an error, which would cause a null pointer dereference when attempting to log the error message in the caller. Fix this by setting an error on all error paths. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/9130 Part-of: --- src/st/st-texture-cache.c | 46 ++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c index 2c7601da1..a30ebfa56 100644 --- a/src/st/st-texture-cache.c +++ b/src/st/st-texture-cache.c @@ -488,15 +488,16 @@ load_pixbuf_async_finish (StTextureCache *cache, GAsyncResult *result, GError ** } static ClutterContent * -pixbuf_to_st_content_image (GdkPixbuf *pixbuf, - CoglContext *context, - int width, - int height, - int paint_scale, - float resource_scale) +pixbuf_to_st_content_image (GdkPixbuf *pixbuf, + CoglContext *context, + int width, + int height, + int paint_scale, + float resource_scale, + GError **error) { ClutterContent *image; - g_autoptr(GError) error = NULL; + g_autoptr(GError) local_error = NULL; float native_width, native_height; @@ -533,11 +534,11 @@ pixbuf_to_st_content_image (GdkPixbuf *pixbuf, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_pixbuf_get_rowstride (pixbuf), - &error); + &local_error); - if (error) + if (local_error) { - g_warning ("Failed to allocate texture: %s", error->message); + g_propagate_error (error, g_steal_pointer (&local_error)); g_clear_object (&image); } @@ -702,13 +703,20 @@ finish_texture_load (AsyncTextureLoadData *data, if (!g_hash_table_lookup_extended (cache->keyed_cache, data->key, &orig_key, &value)) { + g_autoptr (GError) error = NULL; + image = pixbuf_to_st_content_image (pixbuf, data->cogl_context, data->width, data->height, data->paint_scale, - data->resource_scale); + data->resource_scale, + &error); if (!image) - goto out; + { + g_warning ("Failed to load pixbuf into a content: %s", + error->message); + goto out; + } g_hash_table_insert (cache->keyed_cache, g_strdup (data->key), g_object_ref (image)); @@ -720,13 +728,20 @@ finish_texture_load (AsyncTextureLoadData *data, } else { + g_autoptr (GError) error = NULL; + image = pixbuf_to_st_content_image (pixbuf, data->cogl_context, data->width, data->height, data->paint_scale, - data->resource_scale); + data->resource_scale, + &error); if (!image) - goto out; + { + g_warning ("Failed to load pixbuf into a content: %s", + error->message); + goto out; + } } if (data->icon_info) @@ -1221,7 +1236,8 @@ st_texture_cache_load_file_sync_to_cogl_texture (StTextureCache *cache, image = pixbuf_to_st_content_image (pixbuf, context, available_height, available_width, - paint_scale, resource_scale); + paint_scale, resource_scale, + error); g_object_unref (pixbuf); if (!image) -- 2.39.5